# 拉取镜像
docker pull 10.10.181.48/emis/emis_edda_hsbc:CID_TAG_VERSION
# 如果已经有container在运行，删掉
output=$(docker ps -a |grep emis_edda_hsbc)
echo $output
if [ ! -n "$output" ]; then
    echo "container not exit"
else
    docker stop emis_edda_hsbc
    docker rm emis_edda_hsbc
fi
# 日志挂载目录，不存在则创建
path="/opt/EMISLogs/EMIS-EDDA-HSBCLogs"
config_path="/opt/EMIS-EDDA-HSBC/config/"
if [ -d ${path} ];then
    echo dir ${path} exist!
else
    echo dir ${path} not exist!
    mkdir -p ${path}
fi

#使用Jenkins的时候，会报ifconfig:command not fund。需要改下Jenkins环境变量，或者指定为全路径
localIp=$(/usr/sbin/ifconfig -a|grep ens -C 2|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|grep -v ^172 |tr -d "addr:")
httpPort=8280
managementPort=7280
echo ${localIp}:${httpPort}

# 启动
docker run --net=host \
-e JAVA_LOCALIP=${localIp} \
-e JAVA_OPTS='-Dspring.profiles.active=dev' \
--restart=always \
-itd --name emis_edda_hsbc \
-p ${httpPort}:80 \
-p ${managementPort}:${managementPort} \
-v ${path}:/app/logs \
-v ${config_path}:/app/config \
10.10.181.48/emis/emis_edda_hsbc:CID_TAG_VERSION
